home *** CD-ROM | disk | FTP | other *** search
- package sun.beans.editors;
-
- import java.beans.PropertyEditorSupport;
-
- public class BoolEditor extends PropertyEditorSupport {
- public String getAsText() {
- return (Boolean)((PropertyEditorSupport)this).getValue() ? "True" : "False";
- }
-
- public String getJavaInitializationString() {
- return (Boolean)((PropertyEditorSupport)this).getValue() ? "true" : "false";
- }
-
- public String[] getTags() {
- String[] result = new String[]{"True", "False"};
- return result;
- }
-
- public void setAsText(String text) throws IllegalArgumentException {
- if (text.toLowerCase().equals("true")) {
- ((PropertyEditorSupport)this).setValue(Boolean.TRUE);
- } else {
- if (!text.toLowerCase().equals("false")) {
- throw new IllegalArgumentException(text);
- }
-
- ((PropertyEditorSupport)this).setValue(Boolean.FALSE);
- }
-
- }
- }
-